/*
 * Copyright (C) 2013 se-pro group
 * 
 */

package com.sepro.tim;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public abstract class DashboardActivity extends Activity 
{

	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
	}

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        return true;
    }

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.menu_calendar:
	        setContentView(R.layout.activity_calendar);
			Toast.makeText(this, "Menu Calendar Selected", Toast.LENGTH_SHORT).show();
			break;			
		case R.id.menu_timetable:
			setContentView(R.layout.activity_timetables);
			Toast.makeText(this, "Menu Timetable Selected", Toast.LENGTH_SHORT).show();
			break;			
		case R.id.menu_ganttchart:
			setContentView(R.layout.activity_ganttchart);
			Toast.makeText(this, "Menu Gantt-Chart Selected", Toast.LENGTH_SHORT).show();
			break;			
		case R.id.menu_project:
			setContentView(R.layout.activity_projects);
			Toast.makeText(this, "Menu Project Selected", Toast.LENGTH_SHORT).show();
			break;			
		case R.id.menu_settings:
			setContentView(R.layout.activity_settings);
			Toast.makeText(this, "Menu Setting Selected", Toast.LENGTH_SHORT).show();
			break;			
		case R.id.menu_about_team:
			setContentView(R.layout.activity_about);
			Toast.makeText(this, "Menu About Selected", Toast.LENGTH_SHORT).show();
			break;
		}
		
		return true;
	}

	protected void onDestroy ()
	{
		super.onDestroy ();
	}

	protected void onPause ()
	{
		super.onPause ();
	}

	protected void onRestart ()
	{
		super.onRestart ();
	}

	protected void onResume ()
	{
		super.onResume ();
	}

	protected void onStart ()
	{
		super.onStart ();
	}

	protected void onStop ()
	{
		super.onStop ();
	}
	
	public void onClickHome (View v)
	{
		goHome (this);
	}

	public void onClickSearch (View v)
	{
		startActivity (new Intent(getApplicationContext(), SearchActivity.class));
	}

	public void onClickHelp (View v)
	{
		startActivity (new Intent(getApplicationContext(), HelpActivity.class));
	}

	public void onClickFeature (View v)
	{
	    int id = v.getId ();
	    switch (id) {
	      case R.id.home_btn_calendar:
	    	  	startActivity (new Intent(getApplicationContext(), CalendarActivity.class));
	    	  	break;
	      case R.id.home_btn_project:
	    	  	startActivity (new Intent(getApplicationContext(), ProjectsActivity.class));
	    	  	break;
	      case R.id.home_btn_timetable:
	    	  	startActivity (new Intent(getApplicationContext(), TimetablesActivity.class));
	    	  	break;
	      case R.id.home_btn_gantt_chart:
	    	  	startActivity (new Intent(getApplicationContext(), GanttchartActivity.class));
	    	  	break;
	      case R.id.home_btn_setting:
	    	  	startActivity (new Intent(getApplicationContext(), SettingsActivity.class));
	    	  	break;
	      case R.id.home_btn_about:
	    	  	startActivity (new Intent(getApplicationContext(), AboutActivity.class));
	    	  	break;
	    }
	}

	public void goHome(Context context) 
	{
		final Intent intent = new Intent(context, MainActivity.class);
		intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
	    context.startActivity (intent);
	}

	public void setTitleFromActivityLabel (int textViewId)
	{
	    TextView tv = (TextView) findViewById (textViewId);
	    if (tv != null) tv.setText (getTitle ());
	}

	public void toast (String msg)
	{
	    Toast.makeText (getApplicationContext(), msg, Toast.LENGTH_SHORT).show ();
	}
	
	public void trace (String msg) 
	{
	    Log.d("Demo", msg);
	    toast (msg);
	}

}
